<?
require_once("base/BaseDownloadForm.php");
require_once("cms/download/om/Download.php");
require_once("cms/core/om/Image.php");

class DownloadForm extends BaseDownloadForm {

    private $log;

    public function __construct() {
        parent::__construct();
        $this->log =& LoggerManager::getLogger("DownloadForm");
        $this->getRevision()->setDownload(new Download());
        $this->getRevision()->getDownload()->setImageRelatedByImageId(new Image());
        $this->getRevision()->getDownload()->setImageRelatedByThumbnailId(new Image());
    }

    public function validate() {

        global $ALLOWABLE_IMAGES;

        $ALLOWABLE_IMAGES = array(
            "image/jpeg"=>"jpg",
            "image/pjpeg"=>"jpg",
            "image/gif"=>"gif",
            "image/png"=>"png"
        );

        $errors = parent::validate();

        if($this->getRevision()->getDownloadRevisionId() == 0 && $this->formFile["size"] == 0)
            $errors->add("formFile",
                new ActionMessage("errors.required", true, new ActionMessage("prompt.file", true)));

        return $errors;
    }

}
?>